{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.548521Z",
     "start_time": "2024-04-17T09:46:06.543657Z"
    }
   },
   "source": [
    "# 加载数据\n",
    "data = open('data/nietzsche.txt', encoding='utf-8').read()\n",
    "data = data.replace('\\n', '').replace('\\r', '')\n",
    "print(data)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world\n"
     ]
    }
   ],
   "execution_count": 199
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.567518Z",
     "start_time": "2024-04-17T09:46:06.563481Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 字符去重\n",
    "letters = list(set(data))\n",
    "print(letters)\n",
    "\n",
    "print(\"\\n\")\n",
    "\n",
    "num_letters = len(letters)\n",
    "print(num_letters)"
   ],
   "id": "d8e70c4008cd29e5",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['r', ' ', 'd', 'e', 'w', 'h', 'o', 'l']\n",
      "\n",
      "\n",
      "8\n"
     ]
    }
   ],
   "execution_count": 200
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.594940Z",
     "start_time": "2024-04-17T09:46:06.587456Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 建立字典\n",
    "int_to_char = {i: c for i, c in enumerate(letters)}\n",
    "print(int_to_char)\n",
    "\n",
    "print(\"\\n\")\n",
    "\n",
    "char_to_int = {c: i for i, c in enumerate(letters)}\n",
    "print(char_to_int)"
   ],
   "id": "ef0c08ed475107d5",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0: 'r', 1: ' ', 2: 'd', 3: 'e', 4: 'w', 5: 'h', 6: 'o', 7: 'l'}\n",
      "\n",
      "\n",
      "{'r': 0, ' ': 1, 'd': 2, 'e': 3, 'w': 4, 'h': 5, 'o': 6, 'l': 7}\n"
     ]
    }
   ],
   "execution_count": 201
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.600883Z",
     "start_time": "2024-04-17T09:46:06.596939Z"
    }
   },
   "cell_type": "code",
   "source": "time_step = 100",
   "id": "8d81d888b114761",
   "outputs": [],
   "execution_count": 202
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.617088Z",
     "start_time": "2024-04-17T09:46:06.605878Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import numpy as np\n",
    "from keras.utils import to_categorical\n",
    "\n",
    "\n",
    "def extract_data(data, slide):\n",
    "    \"\"\"\n",
    "    滑动窗口提取数据\n",
    "    :param data: \n",
    "    :param slide: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    x = []\n",
    "    y = []\n",
    "\n",
    "    for i in range(len(data) - slide):\n",
    "        x.append([a for a in data[i:i + slide]])\n",
    "        y.append(data[i + slide])\n",
    "    return x, y\n",
    "\n",
    "\n",
    "def char_to_int_data(x, y, char_to_int):\n",
    "    \"\"\"\n",
    "    字符转数字\n",
    "    :param x: \n",
    "    :param y: \n",
    "    :param char_to_int: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    x_to_int = []\n",
    "    y_to_int = []\n",
    "\n",
    "    for i in range(len(x)):\n",
    "        x_to_int.append([char_to_int[c] for c in x[i]])\n",
    "        y_to_int.append([char_to_int[c] for c in y[i]])\n",
    "    return x_to_int, y_to_int\n",
    "\n",
    "\n",
    "def data_preprocessing(data, slide, num_letters, char_to_int):\n",
    "    \"\"\"\n",
    "    数据预处理\n",
    "    :param data: \n",
    "    :param slide: \n",
    "    :param num_letters: \n",
    "    :param char_to_int: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    chart_data = extract_data(data, slide)\n",
    "    int_data = char_to_int_data(chart_data[0], chart_data[1], char_to_int)\n",
    "    Input = int_data[0]\n",
    "    Output = list(np.array(int_data[1]).flatten())\n",
    "    Input_RESHAPED = np.array(Input).reshape(len(Input), slide)\n",
    "    new = np.random.randint(0, 10, size=[Input_RESHAPED.shape[0], Input_RESHAPED.shape[1], num_letters])\n",
    "    for i in range(Input_RESHAPED.shape[0]):\n",
    "        for j in range(Input_RESHAPED.shape[1]):\n",
    "            new[i, j, :] = to_categorical(Input_RESHAPED[i, j], num_classes=num_letters)\n",
    "\n",
    "    return new, Output"
   ],
   "id": "bb24af0d1656afef",
   "outputs": [],
   "execution_count": 203
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.691350Z",
     "start_time": "2024-04-17T09:46:06.619086Z"
    }
   },
   "cell_type": "code",
   "source": [
    "x, y = data_preprocessing(data, time_step, num_letters, char_to_int)\n",
    "\n",
    "print(x, \"\\n\", len(x), \"\\n\", x.shape)\n",
    "print(y, \"\\n\", len(y))"
   ],
   "id": "a5486feaaa704728",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[0 0 0 ... 1 0 0]\n",
      "  [0 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  ...\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  [0 0 1 ... 0 0 0]\n",
      "  [0 0 0 ... 1 0 0]]\n",
      "\n",
      " [[0 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  ...\n",
      "  [0 0 1 ... 0 0 0]\n",
      "  [0 0 0 ... 1 0 0]\n",
      "  [0 0 0 ... 0 0 0]]\n",
      "\n",
      " [[0 0 0 ... 0 0 1]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  [0 0 0 ... 0 1 0]\n",
      "  ...\n",
      "  [0 0 0 ... 1 0 0]\n",
      "  [0 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]]\n",
      "\n",
      " ...\n",
      "\n",
      " [[0 0 0 ... 0 1 0]\n",
      "  [1 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  ...\n",
      "  [0 1 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 1 0]]\n",
      "\n",
      " [[1 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]\n",
      "  [0 0 1 ... 0 0 0]\n",
      "  ...\n",
      "  [0 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 1 0]\n",
      "  [1 0 0 ... 0 0 0]]\n",
      "\n",
      " [[0 0 0 ... 0 0 1]\n",
      "  [0 0 1 ... 0 0 0]\n",
      "  [0 0 0 ... 1 0 0]\n",
      "  ...\n",
      "  [0 0 0 ... 0 1 0]\n",
      "  [1 0 0 ... 0 0 0]\n",
      "  [0 0 0 ... 0 0 1]]] \n",
      " 32 \n",
      " (32, 100, 8)\n",
      "[3, 7, 7, 6, 1, 4, 6, 0, 7, 2, 5, 3, 7, 7, 6, 1, 4, 6, 0, 7, 2, 5, 3, 7, 7, 6, 1, 4, 6, 0, 7, 2] \n",
      " 32\n"
     ]
    }
   ],
   "execution_count": 204
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.703804Z",
     "start_time": "2024-04-17T09:46:06.693245Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.1, random_state=10)\n",
    "\n",
    "print(x_train.shape, len(y_train))"
   ],
   "id": "fadc09cd0c1ea6",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(28, 100, 8) 28\n"
     ]
    }
   ],
   "execution_count": 205
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.711204Z",
     "start_time": "2024-04-17T09:46:06.704809Z"
    }
   },
   "cell_type": "code",
   "source": [
    "y_train_category = to_categorical(y_train, num_letters)\n",
    "print(y_train_category)"
   ],
   "id": "ea079d01bbc96400",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [0. 0. 0. 0. 0. 1. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [1. 0. 0. 0. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [0. 0. 0. 1. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 0. 0. 1. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 1. 0. 0.]\n",
      " [0. 0. 0. 0. 1. 0. 0. 0.]\n",
      " [0. 0. 1. 0. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 0. 1.]\n",
      " [0. 1. 0. 0. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 1. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [0. 0. 0. 0. 0. 0. 1. 0.]\n",
      " [0. 0. 0. 1. 0. 0. 0. 0.]\n",
      " [0. 1. 0. 0. 0. 0. 0. 0.]\n",
      " [0. 1. 0. 0. 0. 0. 0. 0.]\n",
      " [1. 0. 0. 0. 0. 0. 0. 0.]\n",
      " [0. 0. 1. 0. 0. 0. 0. 0.]]\n"
     ]
    }
   ],
   "execution_count": 206
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:06.760675Z",
     "start_time": "2024-04-17T09:46:06.712326Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from keras import Input\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense, LSTM\n",
    "\n",
    "model = Sequential()\n",
    "model.add(Input((x_train.shape[1], x_train.shape[2])))\n",
    "model.add(LSTM(units=20, activation='relu'))\n",
    "model.add(Dense(units=num_letters, activation='softmax'))\n",
    "model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n",
    "model.summary()"
   ],
   "id": "3793132259f24795",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001B[1mModel: \"sequential_11\"\u001B[0m\n"
      ],
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">Model: \"sequential_11\"</span>\n",
       "</pre>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
       "┃\u001B[1m \u001B[0m\u001B[1mLayer (type)                   \u001B[0m\u001B[1m \u001B[0m┃\u001B[1m \u001B[0m\u001B[1mOutput Shape          \u001B[0m\u001B[1m \u001B[0m┃\u001B[1m \u001B[0m\u001B[1m      Param #\u001B[0m\u001B[1m \u001B[0m┃\n",
       "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
       "│ lstm_11 (\u001B[38;5;33mLSTM\u001B[0m)                  │ (\u001B[38;5;45mNone\u001B[0m, \u001B[38;5;34m20\u001B[0m)             │         \u001B[38;5;34m2,320\u001B[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense_11 (\u001B[38;5;33mDense\u001B[0m)                │ (\u001B[38;5;45mNone\u001B[0m, \u001B[38;5;34m8\u001B[0m)              │           \u001B[38;5;34m168\u001B[0m │\n",
       "└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
      ],
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
       "┃<span style=\"font-weight: bold\"> Layer (type)                    </span>┃<span style=\"font-weight: bold\"> Output Shape           </span>┃<span style=\"font-weight: bold\">       Param # </span>┃\n",
       "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
       "│ lstm_11 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">LSTM</span>)                  │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">20</span>)             │         <span style=\"color: #00af00; text-decoration-color: #00af00\">2,320</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense_11 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>)                │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">8</span>)              │           <span style=\"color: #00af00; text-decoration-color: #00af00\">168</span> │\n",
       "└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
       "</pre>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\u001B[1m Total params: \u001B[0m\u001B[38;5;34m2,488\u001B[0m (9.72 KB)\n"
      ],
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Total params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">2,488</span> (9.72 KB)\n",
       "</pre>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\u001B[1m Trainable params: \u001B[0m\u001B[38;5;34m2,488\u001B[0m (9.72 KB)\n"
      ],
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">2,488</span> (9.72 KB)\n",
       "</pre>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\u001B[1m Non-trainable params: \u001B[0m\u001B[38;5;34m0\u001B[0m (0.00 B)\n"
      ],
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Non-trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> (0.00 B)\n",
       "</pre>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 207
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.304016Z",
     "start_time": "2024-04-17T09:46:06.761711Z"
    }
   },
   "cell_type": "code",
   "source": "model.fit(x_train, y_train_category, epochs=100, batch_size=1000)",
   "id": "2ee68bcaeff136f4",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m1s\u001B[0m 1s/step - accuracy: 0.0714 - loss: 2.0887\n",
      "Epoch 2/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 43ms/step - accuracy: 0.0714 - loss: 2.0852\n",
      "Epoch 3/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.0714 - loss: 2.0819\n",
      "Epoch 4/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.0714 - loss: 2.0786\n",
      "Epoch 5/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.0714 - loss: 2.0754\n",
      "Epoch 6/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 47ms/step - accuracy: 0.0714 - loss: 2.0723\n",
      "Epoch 7/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 42ms/step - accuracy: 0.0714 - loss: 2.0692\n",
      "Epoch 8/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 44ms/step - accuracy: 0.0714 - loss: 2.0662\n",
      "Epoch 9/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.0714 - loss: 2.0633\n",
      "Epoch 10/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.0000e+00 - loss: 2.0604\n",
      "Epoch 11/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.0000e+00 - loss: 2.0576\n",
      "Epoch 12/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 45ms/step - accuracy: 0.0000e+00 - loss: 2.0548\n",
      "Epoch 13/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.0000e+00 - loss: 2.0520\n",
      "Epoch 14/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.1071 - loss: 2.0492\n",
      "Epoch 15/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 44ms/step - accuracy: 0.1786 - loss: 2.0465\n",
      "Epoch 16/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 2.0437\n",
      "Epoch 17/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 2.0410\n",
      "Epoch 18/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 43ms/step - accuracy: 0.2857 - loss: 2.0383\n",
      "Epoch 19/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 2.0355\n",
      "Epoch 20/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 2.0327\n",
      "Epoch 21/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 2.0298\n",
      "Epoch 22/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 2.0269\n",
      "Epoch 23/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 2.0240\n",
      "Epoch 24/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 2.0209\n",
      "Epoch 25/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 35ms/step - accuracy: 0.2857 - loss: 2.0179\n",
      "Epoch 26/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 42ms/step - accuracy: 0.2857 - loss: 2.0147\n",
      "Epoch 27/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 2.0115\n",
      "Epoch 28/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 2.0083\n",
      "Epoch 29/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 2.0050\n",
      "Epoch 30/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 2.0016\n",
      "Epoch 31/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.9982\n",
      "Epoch 32/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.9947\n",
      "Epoch 33/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.9912\n",
      "Epoch 34/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.9876\n",
      "Epoch 35/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9839\n",
      "Epoch 36/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9801\n",
      "Epoch 37/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9762\n",
      "Epoch 38/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9724\n",
      "Epoch 39/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.9685\n",
      "Epoch 40/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 71ms/step - accuracy: 0.2857 - loss: 1.9642\n",
      "Epoch 41/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.9596\n",
      "Epoch 42/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.9548\n",
      "Epoch 43/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.2857 - loss: 1.9498\n",
      "Epoch 44/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.9445\n",
      "Epoch 45/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.2857 - loss: 1.9387\n",
      "Epoch 46/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9317\n",
      "Epoch 47/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9241\n",
      "Epoch 48/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.9375\n",
      "Epoch 49/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9193\n",
      "Epoch 50/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.2857 - loss: 1.9161\n",
      "Epoch 51/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.9153\n",
      "Epoch 52/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.9148\n",
      "Epoch 53/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9141\n",
      "Epoch 54/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9130\n",
      "Epoch 55/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.9115\n",
      "Epoch 56/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9096\n",
      "Epoch 57/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.9075\n",
      "Epoch 58/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.9051\n",
      "Epoch 59/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.9024\n",
      "Epoch 60/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8994\n",
      "Epoch 61/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8961\n",
      "Epoch 62/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.8925\n",
      "Epoch 63/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.2857 - loss: 1.8888\n",
      "Epoch 64/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 42ms/step - accuracy: 0.2857 - loss: 1.8850\n",
      "Epoch 65/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8813\n",
      "Epoch 66/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8781\n",
      "Epoch 67/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8764\n",
      "Epoch 68/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8767\n",
      "Epoch 69/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8745\n",
      "Epoch 70/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8697\n",
      "Epoch 71/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8665\n",
      "Epoch 72/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8646\n",
      "Epoch 73/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8630\n",
      "Epoch 74/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8613\n",
      "Epoch 75/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8591\n",
      "Epoch 76/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.8566\n",
      "Epoch 77/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8536\n",
      "Epoch 78/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.8503\n",
      "Epoch 79/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8472\n",
      "Epoch 80/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8450\n",
      "Epoch 81/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.8437\n",
      "Epoch 82/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8404\n",
      "Epoch 83/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8369\n",
      "Epoch 84/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8345\n",
      "Epoch 85/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8324\n",
      "Epoch 86/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8297\n",
      "Epoch 87/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8264\n",
      "Epoch 88/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8230\n",
      "Epoch 89/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.8208\n",
      "Epoch 90/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 40ms/step - accuracy: 0.2857 - loss: 1.8180\n",
      "Epoch 91/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8142\n",
      "Epoch 92/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8116\n",
      "Epoch 93/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.8085\n",
      "Epoch 94/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 42ms/step - accuracy: 0.2857 - loss: 1.8045\n",
      "Epoch 95/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.8019\n",
      "Epoch 96/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 36ms/step - accuracy: 0.2857 - loss: 1.7974\n",
      "Epoch 97/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 37ms/step - accuracy: 0.2857 - loss: 1.7942\n",
      "Epoch 98/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 38ms/step - accuracy: 0.2857 - loss: 1.7901\n",
      "Epoch 99/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 41ms/step - accuracy: 0.2857 - loss: 1.7864\n",
      "Epoch 100/100\n",
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 39ms/step - accuracy: 0.2857 - loss: 1.7817\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.src.callbacks.history.History at 0x1320182a5d0>"
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 208
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.496235Z",
     "start_time": "2024-04-17T09:46:12.305015Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# y_train_predict = model.predict_classes(x_train)\n",
    "# print(y_train_predict)\n",
    "\n",
    "predict_y=model.predict(x_train)\n",
    "y_train_predict=np.argmax(predict_y,axis=1)\n",
    "print(y_train_predict)"
   ],
   "id": "a8e0f38e4de7b529",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 145ms/step\n",
      "[7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7]\n"
     ]
    }
   ],
   "execution_count": 209
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.501040Z",
     "start_time": "2024-04-17T09:46:12.497240Z"
    }
   },
   "cell_type": "code",
   "source": [
    "y_train_predict_char = [int_to_char[i] for i in y_train_predict]\n",
    "print(y_train_predict_char)"
   ],
   "id": "d76685cd2bd1abe9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l']\n"
     ]
    }
   ],
   "execution_count": 210
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.507142Z",
     "start_time": "2024-04-17T09:46:12.502043Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import accuracy_score\n",
    "\n",
    "accuracy_train = accuracy_score(y_train, y_train_predict)\n",
    "print(accuracy_train)"
   ],
   "id": "b1c298b0a1f4a66",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.2857142857142857\n"
     ]
    }
   ],
   "execution_count": 211
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.702298Z",
     "start_time": "2024-04-17T09:46:12.508145Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# y_test_predict = model.predict(x_test)\n",
    "\n",
    "predict_x=model.predict(x_test)\n",
    "y_test_predict=np.argmax(predict_x,axis=1)\n",
    "\n",
    "accuracy_test = accuracy_score(y_test, y_test_predict)\n",
    "\n",
    "print(accuracy_test)\n",
    "print(y_test_predict)\n",
    "print(y_test)"
   ],
   "id": "624de3b0ee5bad8c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 149ms/step\n",
      "0.25\n",
      "[7 7 7 7]\n",
      "[2, 0, 4, 7]\n"
     ]
    }
   ],
   "execution_count": 212
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.840208Z",
     "start_time": "2024-04-17T09:46:12.704298Z"
    }
   },
   "cell_type": "code",
   "source": [
    "new_letters = 'He obtained his phd in Astralia.'\n",
    "x_new, y_new = data_preprocessing(data, time_step, num_letters, char_to_int)\n",
    "\n",
    "# y_new_predict = model.predict(x_new)\n",
    "\n",
    "predict_yy=model.predict(x_new)\n",
    "y_new_predict=np.argmax(predict_yy,axis=1)\n",
    "\n",
    "print(y_new_predict)"
   ],
   "id": "8ac301bbffbf4a52",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001B[1m1/1\u001B[0m \u001B[32m━━━━━━━━━━━━━━━━━━━━\u001B[0m\u001B[37m\u001B[0m \u001B[1m0s\u001B[0m 22ms/step\n",
      "[7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7]\n"
     ]
    }
   ],
   "execution_count": 213
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.845299Z",
     "start_time": "2024-04-17T09:46:12.841210Z"
    }
   },
   "cell_type": "code",
   "source": [
    "y_new_predict_char = [int_to_char[i] for i in y_new_predict]\n",
    "print(y_new_predict_char)"
   ],
   "id": "1c25ffa2d8cbf7f9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l', 'l']\n"
     ]
    }
   ],
   "execution_count": 214
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.851510Z",
     "start_time": "2024-04-17T09:46:12.846302Z"
    }
   },
   "cell_type": "code",
   "source": [
    "for i in range(0, x_new.shape[0] - 20):\n",
    "    print(new_letters[i:i + 20], \"-->\",y_new_predict_char[i])"
   ],
   "id": "cb33cf01c81ec67e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "He obtained his phd  --> l\n",
      "e obtained his phd i --> l\n",
      " obtained his phd in --> l\n",
      "obtained his phd in  --> l\n",
      "btained his phd in A --> l\n",
      "tained his phd in As --> l\n",
      "ained his phd in Ast --> l\n",
      "ined his phd in Astr --> l\n",
      "ned his phd in Astra --> l\n",
      "ed his phd in Astral --> l\n",
      "d his phd in Astrali --> l\n",
      " his phd in Astralia --> l\n"
     ]
    }
   ],
   "execution_count": 215
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-17T09:46:12.855813Z",
     "start_time": "2024-04-17T09:46:12.852512Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "1251d23b731fb0a5",
   "outputs": [],
   "execution_count": 215
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
